function SearchXSS (myWindow) {
	this.construct(myWindow);
}

SearchXSS.prototype = {
	TabBrowser        : null,

	construct:  function(myWindow){
		this.myWindow = myWindow;

		const kWindowMediatorContractID = "@mozilla.org/appshell/window-mediator;1";
		const kWindowMediatorIID        = Components.interfaces.nsIWindowMediator;
		const kWindowMediator           = Components.classes[kWindowMediatorContractID].getService(kWindowMediatorIID);

		this.BrowserWindow = kWindowMediator.getMostRecentWindow("navigator:browser");
		this.TabBrowser    = this.BrowserWindow.getBrowser();
	},
		
	gotoSearchXssHome:	function(){
		this.TabBrowser.selectedTab=this.TabBrowser.addTab("http://code.google.com/p/searchxss/");
	},

	//open setting dialog
	openDialogSetting:	function(index) {
		window.openDialog('chrome://searchxss/content/searchxssSetting.xul', null, 'centerscreen,chrome,width=750px,height=300px', attackStringContainer, whiteListContainer, xssUrlContainer, debugParamContainer, index);
		
	},
	
	setCount:	function(xssCount) {
		this.myWindow.document.getElementById("xss-count").setAttribute("value",xssCount);
	},

	caution: function(request) {
		if(xssUrlContainer.addXssUrl(request)){ 
            //发送请求到服务器端
            var xmlhttp = new XMLHttpRequest();
            xmlhttp.open("GET","http://go.alimama.net/searchxss/log.php?xsrc=searchxss&req=" + escape(request), true);
            xmlhttp.send();

			xssCount = xssUrlContainer.getXssUrlsCount();
			//if(this.myWindow.document.getElementById("xss-count").getAttribute("value") == "0")
			//	this.setCount("NEW");
			//else
			this.setCount(xssCount);
		}
	},

    tuneup: function() {
        if(this.myWindow.document.getElementById("J_tuneup").getAttribute("checked")){
			enabledContainer.setEnabled("true");
            httpService.addListener();
            this.myWindow.document.getElementsByClassName("searchxss-button")[0].setAttribute("class","searchxss-button enable");
        }
        else{
			enabledContainer.setEnabled("false");
            httpService.removeListener();
            this.myWindow.document.getElementsByClassName("searchxss-button")[0].setAttribute("class","searchxss-button unable");
        }
    }
}
